import logging
import os.path
import threading
import time
import unittest
import HTMLTestReportCN
<<<<<<< HEAD
from test_case.test_tools_pdf import TestToolsPdf
from utils.common import connect_to_device, get_device_info
from utils.log import logger
from test_case.test_recognize_text import RecognizeText


def test_suit():
    dis = unittest.defaultTestLoader.discover(test_dir, pattern="test*.py")
    suit = unittest.TestSuite(dis)
=======
from common.common import connect_to_device, get_device_info
from common.log import logger
from test_case.test_card_scan_page import TestCardScanPage
from test_case.test_docs_page import TestDocsPage
from test_case.test_picture_reco_page import TestPictureRecoPage
from test_case.test_picture_to_excel import TestPictureToExcel
from test_case.test_picture_to_word import TestPictureToWord


# def test_suit():
#     dis = unittest.defaultTestLoader.discover(test_dir, pattern="test_docs_scan.py")
#     suit = unittest.TestSuite(dis)
#     return suit

def test_suit():
    suit = unittest.TestSuite()
    suit.addTest(TestDocsPage('test_01_import_pdfs'))
>>>>>>> 41acbbe (commit)
    return suit

# def test_suit():
#     suit = unittest.TestSuite()
#     suit.addTest(TestToolsPdf('test_06_pdfMerge'))
#     return suit


if __name__ == '__main__':
<<<<<<< HEAD
    # 测试用例路径
=======
    device_info = get_device_info()
    title = '1.3.7测试报告'
    report_path = os.path.join(os.getcwd() + '\\result')
>>>>>>> 41acbbe (commit)
    test_dir = os.path.join(os.getcwd() + '\\test_case')
    # 设置测试报告路径及文件名
    device_info = get_device_info()
    device_name = device_info.get('Device Model').decode('utf-8')
    title = '1.15.189测试报告'
    dir_and_files = HTMLTestReportCN.DirAndFiles()
    dir_and_files.create_dir(title + device_name)
    report = HTMLTestReportCN.GlobalMsg.get_value("report_path")
    # 执行测试套件，生成测试报告
    with open(report, 'wb') as fp:
        runner = HTMLTestReportCN.HTMLTestRunner(stream=fp,
                                                 title=device_name + title,
                                                 device_name=device_name,
                                                 os_version=device_info.get('Android Version').decode('utf-8'),
                                                 description='基于自动化APP测试框架产生的测试报告')
        runner.run(test_suit())


"""# 选择存放测试报告的目录
day = time.strftime("%Y-%m-%d", time.localtime(time.time()))
tm = time.strftime("%Y-%m-%d_%H_%M_%S", time.localtime(time.time()))
report_path = os.path.join(os.getcwd() + '\\result')
# result_path = os.path.join(report_path, day + tm + '_' + 'report.html')
result_path = os.path.join(report_path, 'report.html')
test_dir = os.path.join(os.getcwd() + '\\test_case')"""

"""定义测试套件（自定组合，根据版本需求进行组装）"""
"""def test_suit():
    suit = unittest.TestSuite()
    suit.addTest(TestDocScanPage('test_1_repair'))
    suit.addTest(TestDocScanPage('test_2_filter'))
    suit.addTest(TestDocScanPage('test_3_file_scan'))
    suit.addTest(TestDocScanPage('test_4_export_pdf'))
    suit.addTest(TestDocScanPage('test_5_export_picture'))
    suit.addTest(TestDocScanPage('test_6_export_long_picture'))
    suit.addTest(TestPictureRecoPage('test_1_picture_reco'))
    suit.addTest(TestPictureRecoPage('test_2_export_word'))
    suit.addTest(TestPictureRecoPage('test_3_export_txt'))
    suit.addTest(TestPictureToExcel('test_1_picture_to_excel'))
    suit.addTest(TestPictureToExcel('test_2_export_excel'))
    suit.addTest(TestPictureToWord('test_1_picture_to_word'))
    suit.addTest(TestPictureToWord('test_2_export_word'))
    suit.addTest(TestUserPage('test_1_edit_nickname'))
    suit.addTest(TestUserPage('test_2_update_user_avatar'))
    suit.addTest(TestCardScanPage('test_1_card_identity'))
    suit.addTest(TestCardScanPage('test_2_card_band'))
    suit.addTest(TestCardScanPage('test_3_card_household'))
    suit.addTest(TestCardScanPage('test_4_card_driving_licence'))
    suit.addTest(TestCardScanPage('test_5_card_permit'))
    suit.addTest(TestDocPage('test_1_import_pictures'))
    suit.addTest(TestDocPage('test_2_import_pdfs'))
    suit.addTest(TestDocPage('test_2_import_pdfs'))
    dis = unittest.defaultTestLoader.discover(test_dir, pattern="test*.py")
    suit = unittest.TestSuite(dis)
    return suit


# 运行主入口
if __name__ == "__main__":

    with open(result_path, 'wb') as fp:
        runner = HTMLTestReportCN.HTMLTestRunner(stream=fp, title='汉王扫描王安卓0.7.58测试报告',
                                                 description='基于自动化APP测试框架产生的测试报告')
        runner.run(test_suit())"""
